// ==PREPROCESSOR== // @name "Playback Order Button (Popup Menu)" // @author "marc2003" // @import "%fb2k_component_path%docs\flags.txt" // @import "%fb2k_component_path%docs\helpers.txt" // ==/PREPROCESSOR== // Jscript Panel 2.3.6.1 のHelpers.txtにはない部分を追加 function button(x, y, w, h, img_src, fn, tiptext) { this.paint = function (gr) { this.img && gr.DrawImage(this.img, this.x, this.y, this.w, this.h, 0, 0, this.img.Width, this.img.Height); } this.trace = function (x, y) { return x > this.x && x < this.x + this.w && y > this.y && y < this.y + this.h; } this.lbtn_up = function (x, y) { this.fn && this.fn(x, y); } this.cs = function (s) { if (s == "hover") { this.img = this.img_hover; tt(this.tiptext); } else { this.img = this.img_normal; } window.RepaintRect(this.x, this.y, this.w, this.h); } this.x = x; this.y = y; this.w = w; this.h = h; this.fn = fn; this.tiptext = tiptext; this.img_normal = gdi.Image(img_src.normal); this.img_hover = img_src.hover ? gdi.Image(img_src.hover) : this.img_normal; this.img = this.img_normal; } function buttons() { this.paint = function (gr) { for (var i in this.buttons) { this.buttons[i].paint(gr); } } this.move = function (x, y) { var temp_btn = null; for (var i in this.buttons) { if (this.buttons[i].trace(x, y)) temp_btn = i; } if (this.btn == temp_btn) return this.btn; if (this.btn) this.buttons[this.btn].cs("normal"); if (temp_btn) this.buttons[temp_btn].cs("hover"); else tt(""); this.btn = temp_btn; return this.btn; } this.leave = function () { if (this.btn) { tt(""); this.buttons[this.btn].cs("normal"); } this.btn = null; } this.lbtn_up = function (x, y) { if (this.btn) { this.buttons[this.btn].lbtn_up(x, y); return true; } else { return false; } } this.buttons = {}; this.btn = null; } function tt(value) { if (tooltip.Text != value) { tooltip.Text = value; tooltip.Activate(); } } // 追加終わり var tooltip = window.CreateTooltip(); // buttons is defined in docs\helpers.txt var b = new buttons(); var PBOArray = ['Default', 'Repeat (Playlist)', 'Repeat (Track)', 'Random', 'Shuffle (tracks)', 'Shuffle (albums)', 'Shuffle (folders)']; on_playback_order_changed(); function on_playback_order_changed() { // button is defined in docs\helpers.txt // arguments are x, y, w, h, {normal image, hover image is optional}, function, tooltip b.buttons.pbo = new button(5, 5, 18, 9, {normal : fb.ComponentPath + 'samples\\basic\\images\\' + PBOArray[plman.PlaybackOrder] + '.png'}, function () { pbo_menu(); }, 'Playback Order'); window.RepaintRect(b.buttons.pbo.x, b.buttons.pbo.y, b.buttons.pbo.w, b.buttons.pbo.h); } function on_paint(gr) { // RGB function is defined in docs\helpers.txt gr.FillGradRect(0, 0, window.Width, window.Height, 270, RGB(25, 40, 51), RGB(38, 60, 76)) b.paint(gr); } function on_mouse_move(x, y) { b.move(x, y); } function on_mouse_lbtn_up(x, y) { b.lbtn_up(x, y); } function on_mouse_leave(x, y) { b.leave(); } function pbo_menu() { var m = window.CreatePopupMenu(); for (var i = 0; i < PBOArray.length; i++) { // MF_STRING is defined in docs\flags.txt m.AppendMenuItem(MF_STRING, i + 1, PBOArray[i]); } m.CheckMenuRadioItem(1, 8, plman.PlaybackOrder + 1); var idx = m.TrackPopupMenu(b.buttons.pbo.x, b.buttons.pbo.y); if (idx > 0) { plman.PlaybackOrder = idx - 1; } m.Dispose(); }